<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>解构赋值</title>
</head>
<body>
<p>解构，把整体拆分成组件，机器人的对象===》解构===》头+躯干+四肢</p>
<script>
    //传统赋值
    var a=1,b=2,c=3;
    console.log(a,b,c);

    //数组的解构赋值[]
    var [a,b,c]=[4,5,6];
    console.log(a,b,c);

    //对象赋值
    var user ={name:"胡长攀",age:20,address:"郑州"};
    //传统的对象属性赋值
    var username = user.name;
    var userage = user.age;
    var useraddress = user.address;
    console.log(username,userage,useraddress);

    //ES6的对象解构赋值{对象的属性}
    var {name,age,address}=user;
    console.log(name,age,address);

    var {address}=user;//相当于 var address=user.address
    console.log(address);

</script>
</body>
</html>